package cn.zeal4j.domain;

/**
 * @author Administrator
 * @file Hibernate
 * @create 2020 09 23 22:09
 */

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name = "user")
public class User implements Serializable {
    private Integer id;
    private String username;
    private String password;
    private Date reg_time;

    public User() {
    }

    public User(Integer id, String username, String password) {
        this.id = id;
        this.username = username;
        this.password = password;
    }

    public User(Integer id, String username, String password, Date reg_time) {
        this(id, username, password);
        this.reg_time = reg_time;
    }

    @Id // 该注解定义实体标识符的属性
    @GeneratedValue(generator = "increment", strategy = GenerationType.AUTO) // 两个主键生成策略，指示Hibernate如何生成
    @GenericGenerator(name = "increment", strategy = "increment")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Temporal(TemporalType.DATE) // 可以对时间类型的数据注解JPA提供的枚举时间类型     DATE,     TIME,     TIMESTAMP;
    @Column(name = "reg_time") // 标注类属性对应的表字段名称
    public Date getReg_time() {
        return reg_time;
    }

    public void setReg_time(Date reg_time) {
        this.reg_time = reg_time;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
